import java.util.*;

public class Test {
    public static void main(String[] args) {
        List<Integer> list2 = new LinkedList<>();
        LinkedList<Integer> list1 = new LinkedList<>();
//        System.out.print(1);
//        System.out.print(2);

        list1.add(12);
        list1.add(23);
        list1.add(34);
        list1.add(45);
        System.out.println(list1);

        System.out.println();
        System.out.println("==foreach循环==");
        for (Integer x:list1) {
            System.out.print(x + " ");
        }

        System.out.println();
        System.out.println("==for循环==");
        for (int i = 0; i < list1.size(); i++) {
            System.out.print(i + " ");
        }

        System.out.println();
        System.out.println("==Iterator迭代器循环==");
        Iterator<Integer> iterator = list1.iterator();
        while(iterator.hasNext()){
            System.out.print(iterator.next()+" ");
        }

        System.out.println();
        System.out.println("==listIterator迭代器循环==");
        ListIterator<Integer> listIterator = list1.listIterator();
        while(listIterator.hasNext()){
            System.out.print(listIterator.next()+" ");
        }

        System.out.println();
        System.out.println("=====listIterator迭代器倒序=====");
        ListIterator<Integer> listIterator1 = list1.listIterator(list1.size());
        while(listIterator1.hasPrevious()){
            System.out.print(listIterator1.previous()+" ");
        }


        Stack<Integer> stack = new Stack<>();
    }
}
